Mule : ActiveMQ Integration
This page last changed on May 31, 2006 by tcarlson.
To configure a default embedded broker. <connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector"> <properties> <property name="specification" value="1.1"/> <property name="connectionFactoryJndiName" value="ConnectionFactory"/> <property name="jndiInitialFactory" value="org.activemq.jndi.ActiveMQInitialContextFactory"/> <map name="connectionFactoryProperties"> <property name="brokerURL" value="vm://localhost"/> <property name="brokerXmlConfig" value="classpath:/org/mule/test/activemq-config.xml"/> </map> </properties> </connector> The specification property tells Mule to use the Jms 1.1 specification, which is the specification ActiveMQ supports. To disable queue persistence, you'll need to specify it in ActiveMQ configuration file (see below).
To configure ActiveMQ on a specific brokerUrl or from an ActiveMQ configuration file use the following (Spring version) mule-config.xml <!-- Give this container a name in case you have more than one container, e.g. Spring, Plexus, JNDI, EJB, etc. You can safely omit it if you don't have these requirements. --> <container-context className="org.mule.extras.spring.SpringContainerContext" name="spring"> <properties> <property name="configFile" value="classpath:/org/mule/test/activemq-spring.xml"/> </properties> </container-context> <connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector"> <properties> <property name="specification" value="1.1"/> <!-- The container name must be the same as above in container-context element or empty (then the first available one will be used. --> <container-property name="connectionFactory" reference="activeMqConnectionFactory" container="spring" </properties> </connector> Configure ActiveMQ from Spring: activemq-spring.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="activeMqConnectionFactory" class="org.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost"/> <property name="brokerXmlConfig" value="classpath:/org/mule/test/activemq-config.xml"/> <!-- More properties you want set on ActiveMQConnectionFactory --> </bean> </beans> Your ActiveMQ config is a standard one. E.g. to use in-JVM messaging without persistent queues (very useful for testing) the file will be as follows: activemq-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//ACTIVEMQ//DTD//EN" "http://activemq.org/dtd/activemq.dtd"> <beans> <broker> <connector> <serverTransport uri="vm://localhost"/> </connector> <persistence> <vmPersistence/> </persistence> </broker> </beans> |
Document generated by Confluence on Nov 27, 2006 10:27 |